<?php
/**
 * ResMania - Reservation System Framework http://resmania.com
 * Copyright (C) 2011  ResMania Ltd.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *
 * @access      public
 * @author      Valentin
 * @copyright   2011 ResMania Ltd.
 * @version     1.2
 * @link        http://docs.resmania.com/api/
 * @since       06-2011
 */
class RM_Plugin_Row extends Zend_Db_Table_Row implements RM_Dependency_Child_Interface {
    const DEPENDENCY_TYPE = 'plugin';

    function delete(){
        $model = new RM_Dependencies();
        $dependencies = $model->getDependencies($this);
        foreach ($dependencies as $row) {            
            $row->delete();
        }        
        parent::delete();
    }

    function getType(){
        return 'plugin';
    }    

    /**
     * Returns RM_Module_Row or a string with module_name if this module
     * is not installed in application
     *
     * @return RM_Module_Row|string
     */
    function getParentModule(){
        $model = new RM_Modules();
        $module = $model->fetchByName($this->module_name)->current();
        return $module;
    }

    function getName(){
        return $this->name;
    }
}